

var runEditor = function(){    
layui.define(['jquery'], function (exports) {
        
        
    
    var mytoolbars = {
        'mini'   : [['source','bold', 'italic', 'underline','strikethrough', 'pasteplain', 'removeformat', 'insertorderedlist', 'insertunorderedlist', 'forecolor', 'backcolor','emotion' ]],
        'normal' : [[
            'fullscreen', 'source', 'fontfamily',  'fontsize','|', 'undo', 'redo', '|','bold', 'italic', 'underline', 'fontborder', 
            'strikethrough',  'autotypeset',  'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 
            'insertunorderedlist', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|','directionalityltr', 'directionalityrtl', 'indent', '|', 'justifyleft', 
            'justifycenter','justifyright', 'justifyjustify', '|', 'link', 'unlink', 'anchor', '|',
            'simpleupload', 'insertimage', 'emotion',   'map', 'template', 'background',  
            'horizontal', 'date', 'time', 'spechars',  'inserttable','searchreplace', 'drafts'
            // 'insertcode', 'attachment', 'music','insertvideo', 'scrawl','customstyle', 'paragraph','superscript', 'subscript', 'removeformat','formatmatch',  'selectall', 'cleardoc','imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
        ]],
    }
    
    // 百度
    var editor = {        
        render: function (e){    
            e.elem = e.elem || 'JS_editor';
            var param = {
                wordCount:false, //关闭字数统计
                elementPathEnabled : false, //是否启用元素路径
                autoHeightEnabled: false,        // 是否自动长高,默认true
                zIndex : 100     //编辑器层级的基数,默认是900
               // scaleEnabled:true,  //编辑器是否可以拖拽大小
            };
            if(typeof e.data != 'undefined') param.initialContent = e.data;
            // 定制工具栏
            if(typeof e.toolbars != 'undefined'){
                if( e.toolbars == 'mini' ){
                    param.toolbars = mytoolbars.mini;
                    param.enableContextMenu = false; // 关闭右键功能
                } 
                if( e.toolbars == 'normal' )  param.toolbars = mytoolbars.normal;
                if( e.toolbars == 'all' )  param.toolbars = window.UEDITOR_CONFIG.toolbars;
            }
            if(typeof param.toolbars == 'undefined')  param.toolbars = mytoolbars.normal;
            //console.log( param );
            var thisEditor = window.UE.getEditor(e.elem,param);
            //console.log(thisEditor);
        }
    };
    exports('editor', editor);
        
});
};

//layui.link(JS_config.base+'/lib/ueditor/themes/default/css/ueeditor.css');
loadJS(JS_config.base+'/lib/ueditor/ueditor.config.js?v=1');
loadJS(JS_config.base+'/lib/ueditor/ueditor.all.js?v=1',runEditor);